{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>问答回复列表</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-9">
                        <form id="layuiForm">
                            <!--<div class="col-sm-2 form-group">-->
                                <!--<select  class="form-control m-b chosen-select search" name="sign_status" id="sign_status">-->
                                    <!--<option  value="">全部</option>-->
                                    <!--<option  value="1">未签到</option>-->
                                    <!--<option  value="2">签到</option>-->
                                    <!--<option  value="2">签退</option>-->
                                <!--</select>-->
                            <!--</div>-->

                            <!--<div class="col-sm-4">-->
                                <!--<div class="input-group" >-->
                                    <!--<input type="text" id="key" class="form-control search" name="key" value="" placeholder="用户昵称|手机号码"/>-->
                                    <!--<span class="input-group-btn">-->
                                        <!--<a  class="btn btn-primary layuiBtn" data-type="reload"><i class="fa fa-search"></i> 搜索</a>-->
                                    <!--</span>-->
                                <!--</div>-->
                            <!--</div>-->
                        </form>

                    </div>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("interlocution/answer")}'
            , page: true
            , where: {id:{:session('interlocution_id')}}
        , even: false //开启隔行背景
                , size: 'lg' //sm小尺寸的表格 lg大尺寸
                // ,width:100

                , cellMinWidth: 80
                , limits: [5, 10, 15, 20, 25, 30]
                , limit: "{:config('pages')}"
                , text: {
            none: '暂无数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
        }
        , loading: true
                , id: 'testReload'
                , cols: [[
            {type: 'checkbox', fixed: 'left',}
            , {type:'numbers', width: 60, title: '序号'}
            , {field: 'answer_id', width: 60, title: 'ID', sort: true, align: 'center'}
            , {field: 'user_username', width: 130, title: '用户昵称', align: 'center'}
            , {field: 'answer_content', width: '', title: '回复内容', align: 'center'}
            , {field: 'answer_time', width: '', title: '回复时间', align: 'center'}
            , {field: 'answer_zang', width: 130, title: '点赞数量', align: 'center'}
            , {field: 'answer_img', width: 130, title: '回复图片', align: 'center',templet:"#imgTpl"}
            , {fixed: 'right', width: 200, title: '操作', align: 'center', toolbar: '#opeBar'}
        ]]
                ,done: function (res, curr, count) {
            $.each(res.data,function(index,item){
                $('#view_'+item['answer_id']).viewer({
                    url: 'data-original',
                });
            });
        }
    });

        //搜索表格重载
        var $ = layui.$, active = {
            reload: function () {
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where:$('#layuiForm').parseForm()
                });
            }

        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['id'])
            });
            return ids;
        }
    });
</script>
<script type="text/html" id="imgTpl">
    <ul onclick="view(this)" id="view_{{d.answer_id}}">
        <li><img data-original="{{d.picture}}" src="{{d.picture}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  /></li>
        {{# if(d.answer_img.length >= 1){ }}
        {{# for(var i=0;i<d.answer_img.length;i++){  }}
        <li style="display:none;"><img data-original="{{d.answer_img[i]}}" src="{{d.answer_img[i]}}" ></li>
        {{# } }}
        {{# } }}
    </ul>
</script>
<!--操作模板-->
<script type="text/html" id="opeBar">
    <a href="javascript:wk.confirm('{{d.answer_id}}','{:url('answerdelete')}','single');" class="btn btn-danger btn-outline btn-xs"><i class="fa fa-trash-o"></i> 删除</a>
    <a href="javascript:location.href = '{:url('update')}?id={{d.answer_id}}';" class="btn btn-primary btn-outline btn-xs"><i class="fa fa-paste"></i>编辑回答</a>

</script>

</body>
</html>